package com.example.location.service;

import com.example.location.dao.StudentJpa;
import com.example.location.bean.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    private StudentJpa studentJpa;
    public List<Student> getAllStudents(){
        return studentJpa.findAll();
    }
    public int add(Student student){
        studentJpa.save(student);
        return 1;
    }
    public int update(Student student){
        studentJpa.save(student);
        return 1;
    }
    public int delete(int id){
        studentJpa.deleteById(id);
        return 1;
    }
    public Student getById(int id){
        return studentJpa.getOne(id);
    }
}
